import 'dart:convert';

import 'package:enterprise_v6_app/app/data/common/choice_bean.dart';
import 'package:enterprise_v6_app/generated/json/base/json_field.dart';
import 'package:enterprise_v6_app/generated/json/major_hazard_entity.g.dart';

export 'package:enterprise_v6_app/generated/json/major_hazard_entity.g.dart';

@JsonSerializable()
class MajorHazardEntity extends ChoiceBean {
  MajorHazardEntity();

  factory MajorHazardEntity.fromJson(Map<String, dynamic> json) => $MajorHazardEntityFromJson(json);

  List<MajorHazardEquipVOList>? equipVOList = [];
  String? hazardCode = '';
  String? id = '';
  String? riskObjectName = '';
  bool _isSelected = false;

  Map<String, dynamic> toJson() => $MajorHazardEntityToJson(this);

  @override
  String toString() {
    return jsonEncode(this);
  }

  @override
  String getId() {
    return id ?? '未知ID';
  }

  @override
  bool getIsChecked() {
    return _isSelected;
  }

  @override
  String getShowName() {
    return riskObjectName ?? '未知名称';
  }

  @override
  setIsChecked(bool isChecked) {
    _isSelected = isChecked;
  }
}

@JsonSerializable()
class MajorHazardEquipVOList {
  MajorHazardEquipVOList();

  factory MajorHazardEquipVOList.fromJson(Map<String, dynamic> json) => $MajorHazardEquipVOListFromJson(json);

  String? equipCode = '';
  String? equipName = '';
  String? equipTypeDicId = '';
  String? equipTypeName = '';
  String? hazardCode = '';
  List<MajorHazardEquipVOListHazardTargetVOList>? hazardTargetVOList = [];
  String? id = '';

  Map<String, dynamic> toJson() => $MajorHazardEquipVOListToJson(this);

  @override
  String toString() {
    return jsonEncode(this);
  }
}

@JsonSerializable()
class MajorHazardEquipVOListHazardTargetVOList {
  MajorHazardEquipVOListHazardTargetVOList();

  factory MajorHazardEquipVOListHazardTargetVOList.fromJson(Map<String, dynamic> json) =>
      $MajorHazardEquipVOListHazardTargetVOListFromJson(json);

  String? lastCollectTime = '';
  int? lastValue = 0;
  String? online = '';
  int? rangeDown = 0;
  int? rangeUp = 0;
  String? targetCode = '';
  String? targetName = '';
  String? targetStatus = '';
  String? targetTypeDicId = '';
  String? targetTypeDicName = '';
  int? thresholdDown = 0;
  int? thresholdDown2 = 0;
  int? thresholdUp = 0;
  int? thresholdUp2 = 0;
  String? unit = '';

  Map<String, dynamic> toJson() => $MajorHazardEquipVOListHazardTargetVOListToJson(this);

  @override
  String toString() {
    return jsonEncode(this);
  }
}
